﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Shared/ContentMaster.master"
    CodeFile="newsList.aspx.cs" Inherits="ltMan_news_newsList" %>

<asp:Content ID="C1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="C2" ContentPlaceHolderID="CPH1" runat="Server">
    <telerik:RadCodeBlock runat="server" ID="block1">
        <script>
            var comboBox1, comboBoxSearch, tree1, treeSearch;
            var urlpath = '<%=ltModel.Str.GetUrlPath(Request.CurrentExecutionFilePath) %>';
            function goAdd() {
                openCWin('添加新闻', urlpath + 'newsAdd.aspx');
            }
            function goEdit(row) {
                var id = row.getDataKeyValue("news_id"), isgov = $('.isgov', row.get_element()).val() == 'True';
                var url = isgov ? "newsGovModify" : "newsModify";
                var title = isgov ? "修改信息" : "修改新闻";
                openCWin(title, urlpath + url + '.aspx?id=' + id);
            }
            function openCWin(text, url) {
                if (top.treeWithTab)
                    top.treeWithTab.findAndOpenTab(url, text, window);
                else
                    location = url;
            }
            function reloadData() {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().rebind();
            }
            function nodeClicking(sender, args) {
                var node = args.get_node();
                if (!node.get_enabled()) {
                    args.set_cancel(true);
                    return;
                }
                setSelectedNode(comboBox1, node);
            }
            function nodeClickingSearch(sender, args) {
                setSelectedNode(comboBoxSearch, args.get_node());
            }
            function setSelectedNode(comboBox, node) {
                comboBox.set_text(node.get_text());
                comboBox.set_value(node.get_value());
                comboBox.trackChanges();
                comboBox.get_items().getItem(0).set_text(node.get_text());
                comboBox.get_items().getItem(0).set_value(node.get_value());
                comboBox.commitChanges();
                comboBox.hideDropDown();
            }
            Sys.Application.add_load(function () {
                comboBox1 = $find("<%= sClass.ClientID %>"), tree1 = $find('<%=sClass.Items[0].FindControl("RadTreeView1").ClientID %>');
                comboBoxSearch = $find("<%= sClassSearch.ClientID %>"), treeSearch = $find('<%=sClassSearch.Items[0].FindControl("RadTreeView1").ClientID %>');
                setSelectedNode(comboBox1, tree1.get_selectedNode() || tree1.get_nodes().getNode(0));
                setSelectedNode(comboBoxSearch, treeSearch.get_selectedNode() || treeSearch.get_nodes().getNode(0));
                $('.grid-inline-edit').click(function () {
                    var isgov = $(this).parent().find('.isgov').val() == 'True';
                    var url = isgov ? "newsGovModify" : "newsModify";
                    var title = isgov ? "修改信息" : "修改新闻";
                    openCWin(title, urlpath + url + '.aspx?id=' + $(this).attr('eid'));
                });
            });
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManagerProxy runat="server" ID="proxy1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="b1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="b2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="b3">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <div class="searchArea">
        <telerik:RadTextBox runat="server" ID="sTitle" EmptyMessage="搜索标题名称" MaxLength="100" />
        <telerik:RadComboBox runat="server" ID="sClassSearch">
            <ItemTemplate>
                <telerik:RadTreeView runat="server" ID="RadTreeView1" DataTextField="classname" DataValueField="class_id"
                    DataFieldID="class_id" DataFieldParentID="father_id" OnClientNodeClicking="nodeClickingSearch" />
            </ItemTemplate>
            <Items>
                <telerik:RadComboBoxItem Text="" />
            </Items>
        </telerik:RadComboBox>
        <telerik:RadButton Icon-PrimaryIconCssClass="icon-search" runat="server" ID="b1"
            OnClick="b1_Click" Text="搜索" />
        <telerik:RadComboBox runat="server" ID="sClass">
            <ItemTemplate>
                <telerik:RadTreeView runat="server" ID="RadTreeView1" DataTextField="classname" DataValueField="class_id"
                    DataFieldID="class_id" DataFieldParentID="father_id" OnClientNodeClicking="nodeClicking" />
            </ItemTemplate>
            <Items>
                <telerik:RadComboBoxItem Text="" />
            </Items>
        </telerik:RadComboBox>
        <telerik:RadButton Icon-PrimaryIconCssClass="icon-change" runat="server" ID="b2"
            OnClick="b2_Click" Text="修改类别" />
        <telerik:RadDateTimePicker runat="server" ID="sDate" DateInput-EmptyMessage="选择时间"
            DateInput-ReadOnly="true" Calendar-FastNavigationSettings-OkButtonCaption="确定"
            Calendar-FastNavigationSettings-CancelButtonCaption="取消" Calendar-FastNavigationSettings-TodayButtonCaption="今天" Width="140" />
        <telerik:RadButton Icon-PrimaryIconCssClass="icon-change" runat="server" ID="b3"
            OnClick="b3_Click" Text="修改时间" />
    </div>
    <telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" OnDeleteCommand="RadGrid1_DeleteCommand"
        OnItemCommand="RadGrid1_ItemCommand" PageSize="12">
        <ClientSettings>
            <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="340" />
        </ClientSettings>
        <MasterTableView CommandItemDisplay="Top" EditMode="PopUp" DataKeyNames="news_id"
            ClientDataKeyNames="news_id">
            <CommandItemTemplate>
                <telerikEx:GridCommandEx ID="GridCommandEx1" runat="server" OnAddClicking="goAdd"
                    OnEditClicking="goEdit" /><span class="pad3blk">
                <telerikEx:VerifyCommandEx runat="server" ID="VerifyCommandEx1" />
                <telerikEx:RecommendCommandEx runat="server" ID="RecommendCommandEx1" />
                <telerik:RadButton ID="cRebuild" runat="server" CommandName="ReBuild" Icon-PrimaryIconCssClass="icon-build" Text="全部重新生成" UseSubmitBehavior="false" ToolTip="全部重新生成" Visible='<%# CurrentUser.IsManager %>' /></span>
            </CommandItemTemplate>
            <PagerTemplate>
                <telerikEx:RadPagerEx ID="RadPagerEx1" runat="server" />
            </PagerTemplate>
            <Columns>
                <telerik:GridClientSelectColumn HeaderStyle-Width="28" ItemStyle-Width="28" />
                <telerik:GridBoundColumn DataField="news_id" Visible="false" />
                <telerik:GridBoundColumn HeaderStyle-Width="70" HeaderText="类别" DataField="classname"
                    DataFormatString="<nobr>{0}</nobr>" />
                <telerik:GridTemplateColumn HeaderText="标题">
                    <ItemTemplate>
                        <nobr><a href="/html/<%# Eval("link") %>" target="_blank"><%#Eval("title") %></a></nobr>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn HeaderStyle-Width="80" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                    HeaderText="时间" DataField="dat" DataFormatString="{0:yyyy-MM-dd}" />
                <telerik:GridBoundColumn HeaderStyle-Width="55" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="发布人" DataField="faburen" DataFormatString="<nobr>{0}</nobr>" />
                <telerik:GridBoundColumn HeaderStyle-Width="55" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="审核人" DataField="shr" DataFormatString="<nobr>{0}</nobr>" />
                <telerik:GridBoundColumn HeaderStyle-Width="55" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="点击数" DataField="hit" />
                <telerik:GridTemplateColumn HeaderStyle-Width="80" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="状态" SortExpression="sh">
                    <ItemTemplate>
                        <%#Convert.ToBoolean(Eval( "sh"))?"已审":"未审" %>&nbsp;<%#Convert.ToBoolean(Eval("tj")) ? "推荐" : "未荐"%>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderStyle-Width="50" HeaderStyle-HorizontalAlign="Center"
                    ItemStyle-HorizontalAlign="Center" HeaderText="操作">
                    <ItemTemplate>
                        <input type="hidden" class="isgov" value="<%# Eval("focus") %>" />
                        <telerikEx:GridInlineCommandEx ID="GridInlineCommandEx1" runat="server" UseExternalEdit="true"
                            EditParameter='<%# Eval("news_id") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</asp:Content>